package me.send.data.service.provider;

import java.util.Map;

import me.send.business.base.SendVariable;
import me.send.data.service.pojo.Role;

public class RoleProvider {
	
	
	// 批量删除 
	public String batch_delete(Map<String, Object> parameter) {
		String roleids = (String) parameter.get("roleids");
		String sql = "";
		if(roleids!=null && !roleids.equals("")){
			sql = "delete from role where roleid in ("+roleids+")";
		}
		return sql;
	}
	
	public String list_page(Map<String, Object> parameter){
		String sql = "select * from role where 1=1 ";
		Role role = (Role) parameter.get(SendVariable.DATA);
		if (role!=null) {
			if (role.getRolename()!=null && !role.getRolename().equals("")) {
				sql += " and rolename like CONCAT('%',#{DATA.rolename},'%' )";
			}
			if (role.getStatus()>0) {
				sql += " and status = #{DATA.status}";
			}
		}
		sql += " limit #{PAGE.start},#{PAGE.rows} ";
		return sql;
	}
	
	
	public String count(Map<String, Object> parameter){
		String sql = "select count(1) as total from role where 1=1 ";
		Role role = (Role) parameter.get(SendVariable.DATA);
		if (role!=null) {
			if (role.getRolename()!=null && !role.getRolename().equals("")) {
				sql += " and rolename like CONCAT('%',#{DATA.rolename},'%' )";
			}
			if (role.getStatus()>0) {
				sql += " and status = #{DATA.status}";
			}
		}
		return sql;
	}
	
}
